package com.laowang.project.system.service.impl;

import java.util.Date;
import java.util.List;

import com.laowang.common.utils.DateUtil;
import com.laowang.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.laowang.project.system.mapper.MyCyhVipShareMapper;
import com.laowang.project.system.domain.MyCyhVipShare;
import com.laowang.project.system.service.MyCyhVipShareService;

/**
 * vip分享Service业务层处理
 *
 * @author laowang
 * @date 2023-06-16
 */
@Service
public class MyCyhVipShareServiceImpl implements MyCyhVipShareService {
    @Autowired
    private MyCyhVipShareMapper myCyhVipShareMapper;

    /**
     * 查询vip分享
     *
     * @param id vip分享ID
     * @return vip分享
     */
    @Override
    public MyCyhVipShare selectMyCyhVipShareById(Integer id) {
        return myCyhVipShareMapper.selectMyCyhVipShareById(id);
    }

    /**
     * 查询vip分享列表
     *
     * @param myCyhVipShare vip分享
     * @return vip分享
     */
    @Override
    public List<MyCyhVipShare> selectMyCyhVipShareList(MyCyhVipShare myCyhVipShare) {
        return myCyhVipShareMapper.selectMyCyhVipShareList(myCyhVipShare);
    }

    /**
     * 新增vip分享
     *
     * @param myCyhVipShare vip分享
     * @return 结果
     */
    @Override
    public int insertMyCyhVipShare(MyCyhVipShare myCyhVipShare) {
        myCyhVipShare.setCreateTime(DateUtils.getNowDate());
        //过期时间为一天
        myCyhVipShare.setEndTime( DateUtils.addDays(new Date(), 1));
        return myCyhVipShareMapper.insertMyCyhVipShare(myCyhVipShare);
    }

    /**
     * 修改vip分享
     *
     * @param myCyhVipShare vip分享
     * @return 结果
     */
    @Override
    public int updateMyCyhVipShare(MyCyhVipShare myCyhVipShare) {
        return myCyhVipShareMapper.updateMyCyhVipShare(myCyhVipShare);
    }

    /**
     * 批量删除vip分享
     *
     * @param ids 需要删除的vip分享ID
     * @return 结果
     */
    @Override
    public int deleteMyCyhVipShareByIds(Integer[] ids) {
        return myCyhVipShareMapper.deleteMyCyhVipShareByIds(ids);
    }

    /**
     * 删除vip分享信息
     *
     * @param id vip分享ID
     * @return 结果
     */
    @Override
    public int deleteMyCyhVipShareById(Integer id) {
        return myCyhVipShareMapper.deleteMyCyhVipShareById(id);
    }
}
